import {
  VxeButton,
  VxeIcon,
  VxeInput,
  VxeLoading,
  VxePager,
  VxeSelect,
  VxeTooltip,
  VxeUI,
} from 'vxe-pc-ui'

import {
  VxeColgroup,
  VxeColumn,
  VxeGrid,
  VxeTable,
  VxeToolbar,
} from 'vxe-table'

// // 导入默认的语言
import zhCN from 'vxe-table/lib/locale/lang/zh-CN'
// 导入主题变量，也可以重写主题变量
import 'vxe-table/styles/cssvar.scss'

import 'vxe-pc-ui/styles/cssvar.scss'
//
VxeUI.setI18n('zh-CN', zhCN)
VxeUI.setLanguage('zh-CN')

VxeUI.setConfig({
  loadingText: '加载中。。。',
  table: {
    stripe: false,
    round: true,
    border: 'default',
    checkboxConfig: {
      reserve: true,
    },
    // rowConfig: {
    //   isHover: true,
    // },
  },
  grid: {
    align: 'center',
    border: false,
    columnConfig: {
      resizable: true,
    },
    round: true,
    showOverflow: true,
    pagerConfig: {
      layouts: ['Sizes', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump', 'FullJump', 'Total'],
      pageSizes: [10, 20, 50, 100],
      autoHidden: false,
    },
  },
})
export function LazyVxeUI(app) {
  app.use(VxeButton)
  app.use(VxeIcon)
  app.use(VxeLoading)
  app.use(VxePager)
  app.use(VxeSelect)
  app.use(VxeTooltip)
  app.use(VxeInput)
}

export function LazyVxeTable(app) {
  app.use(VxeTable)
  app.use(VxeColumn)
  app.use(VxeColgroup)
  app.use(VxeGrid)
  app.use(VxeToolbar)
}

export function tableOptions(id = 'id') {
  return {
    showOverflow: 'tooltip',
    showHeaderOverflow: true,
    maxHeight: window.innerHeight - 235,
    rowConfig: {
      isHover: true,
      keyField: id,
    },
    toolbarConfig: {
      slots: {
        buttons: 'toolbar_buttons',
      },
      refresh: true,
      zoom: true,
      custom: true,
    },
    border: 'inner',
    pagerConfig: {},
  }
}
